package com.lzh.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzh.mapper.CTMapper;
import com.lzh.pojo.CT;
import com.lzh.pojo.Class;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @author reborn
 * @create 2020/5/21-13:09
 */
@Service
public class CTServiceImple implements CTService {

    @Autowired
    CTMapper ctMapper;

    @Override
    public List<CT> selectTeacherClass(int id) {
        return ctMapper.selectTeacherClass(id);
    }

    @Override
    public  List<Class> selectCname(List<Integer> ids) {
        return ctMapper.selectCname(ids);
    }

    @Override
    public PageInfo<Class> selectCname(Integer pageNum, Integer pageSize, List<Integer> ids) {
        PageHelper.startPage(pageNum,pageSize);
        List<Class> classes = ctMapper.selectCname(ids);
        PageInfo<Class> classPageInfo = new PageInfo<>(classes);
        return classPageInfo;
    }

    @Override
    public CT selectCT(int id) {
        return ctMapper.selectCT(id);
    }

    @Override
    public CT selectTeaStu(int id) {
        return ctMapper.selectTeaStu(id);
    }

    @Override
    public List<Integer>  selectCidByTid(int id) {
        return ctMapper.selectCidByTid(id);
    }

    @Override
    public Set<Integer> selectTidByCid(List<Integer> ids) {
        return ctMapper.selectTidByCid(ids);
    }

    @Override
    public List<CT> selectTeaByCid(int id) {
        return ctMapper.selectTeaByCid(id);
    }

    @Override
    public int deleteCidByTid(int id) {
        return ctMapper.deleteCidByTid(id);
    }

    @Override
    public int addTtoC(CT ct) {
        return ctMapper.addTtoC(ct);
    }

    @Override
    public int deleteOCidByTid(CT ct) {
        return ctMapper.deleteOCidByTid(ct);
    }

    @Override
    public int deleteClass(int id) {
        return ctMapper.deleteClass(id);
    }


    @Override
    public int addClass(Class cla) {
        return ctMapper.addClass(cla);
    }

    @Override
    public PageInfo<Class>  selectClassByName(Integer pageNum,Integer pageSize,String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<Class> classes = ctMapper.selectClassByName(name);
        PageInfo<Class> tPageInfo = new PageInfo<>(classes);
        return tPageInfo;
    }

    @Override
    public int delCTBycid(int cid) {
        return ctMapper.delCTBycid(cid);
    }

    @Override
    public int deleteStuByCid(int cid) {
        return ctMapper.deleteStuByCid(cid);
    }

}
